import allure
from appium.webdriver.common.appiumby import AppiumBy

from .base import Base


class AddressBookPage(Base):    # 通讯录页
    # 添加成员
    __ADD_MEMBER = (AppiumBy.XPATH, '//*[@text="添加成员"]')
    # 管理成员
    __MANAGE = (AppiumBy.XPATH, '//*[@resource-id="android:id/content"]/*/*/*[2]/*[1]/*[1]/*[3]/*[2]')

    def go_add_member(self):
        with allure.step("添加成员"):
            self.swip_by(self.__ADD_MEMBER, operator="click", max_count=99)
            from .add_member import AddMember
            return AddMember(self.driver)

    def go_manage(self):
        with allure.step("管理成员"):
            self.find_click(self.__MANAGE)
            from .manage import Manage
            return Manage(self.driver)
